import instance from "../base"

// 添加购物车
export const addCar = (g_id) =>{
    return instance.post('/addCar', {
        params:{
            g_id: g_id,
            uname: localStorage.getItem('userName')
        },
        headers: {
            Authorization: localStorage.getItem('token')
        }
    })
}


// 获取购物车列表
export const getCarDetail = (userName) =>{
    return instance.get('/getCarDetail', {
        params:{
            userName
        },
        headers: {
            Authorization: localStorage.getItem('token')
        }
    })
}


//! 删除购物车单个商品
// const token = localStorage.getItem('token');
// const tokenWithoutBearer = token.replace(/^Bearer\s/, '');
export const delCarItem = ( g_id) =>{
    return instance.post('/delCarItem', {
        params:{
            id: g_id
        }
    })
}


//! 更新单个购物车的用户选择数量
export const updateCarItem  = (id,num ) =>{
    return instance.post('/updateItemNum', {
        params:{
            id,
            num
        }
    })
} 